{extend name="platform/base" /}
{block name="resources"/}
<style>
    .active>.text-active {
        display: inline-block !important;
    }
    .text-active, .active>.text {
        display: none;
    }
</style>

{/block}

{block name="main"}
<header class="header clearfix">
    <div class="row m-t-sm">
        <a href="{:__URL('PLATFORM_MAIN/System/editMoudel')}" class="btn btn-sm btn-primary"><i class="fa fa-plus"></i> 添加第三方</a>
    </div>
</header>
<section class="panel panel-default">
    <table style="width: 90%;table-layout:fixed;text-align: center" class="table table-striped b-light text-sm">
        <thead>
        <tr>
            <th width="10"></th>
            <th width="90">第三方名称</th>
            <th class="center">参数</th>
            <th class="center">参数值</th>
            <th class="center">添加时间</th>
            <th class="center">是否可用</th>
            <th class="center" width="100">操作</th>
        </tr>
        </thead>
        <tbody>
            {foreach name="list" item="v1"}
            <tr>
                <td width="10">
                    {if condition="$v1['param'] neq array()"}
                    <a href="javascript:;" onclick="tab_switch({$v1['moudelID']})" class="tab_jia_{$v1['moudelID']}" style="display: block;">
                        <i class="fa fa-plus"></i>
                    </a>
                    <a href="javascript:;" onclick="tab_switch({$v1['moudelID']})" class="tab_jian_{$v1['moudelID']}" style="display: none;">
                        <i class="fa fa-minus"></i>
                    </a>
                    {/if}
                </td>
                <td width="90">{$v1['moudeName']}</td>
                <td class="center"></td>
                <td class="center"></td>
                <td class="center">{:date('Y-m-d H:i',$v1['cTime'])}</td>
                <td class="center">
                    <a href="#" class="{$v1['isEnable'] ? 'active' : ''}" data-toggle="class" onclick="changeField({$v1['moudelID']}, 'isEnable', {$v1['isEnable'] ? 0 : 1});">
                        <i class="fa fa-check text-success text-active"></i>
                        <i class="fa fa-times text-danger text"></i>
                    </a>
                </td>
                <td class="center" width="100">
                    <a href="{:__URL('PLATFORM_MAIN/System/editMoudel?moudelID='.$v1['moudelID'])}" title="新增">修改</a>
                    <a href="{:__URL('PLATFORM_MAIN/System/editParam?moudelID='.$v1['moudelID'])}" title="新增">新增</a>
                    <a href="javascript:void(0);" onclick="delModule({$v3['module_id']})" title="删除">删除</a>
                </td>
            </tr>
            {foreach name="v1['param']" item="v2"}
            <tr class="pid_{$v1['moudelID']}"
                style="display: none;">
                <td><label></td>
                <td width="90"></td>
                <td class="center">{$v2['param']}</td>
                <td class="center">{$v2['paramValue']}</td>
                <td class="center">{:date('Y-m-d H:i',$v2['cTime'])}</td>
                <td class="center">
                    <a href="#" class="{$v1['isEnable'] ? 'active' : ''}" data-toggle="class" onclick="changeField2({$v2['paramID']}, 'isEnable', {$v2['isEnable'] ? 0 : 1});">
                        <i class="fa fa-check text-success text-active"></i>
                        <i class="fa fa-times text-danger text"></i>
                    </a>
                </td>
                <td class="center" width="100">
                    <a href="{:__URL('PLATFORM_MAIN/System/editParam?paramID='.$v2['paramID'].'&moudelID='.$v1['moudelID'])}" title="修改">修改</a>
                    <a href="javascript:void(0);" onclick="delModule({$v3['module_id']})">删除</a>
                </td>
            </tr>
            {/foreach}
            {/foreach}
        </tbody>
    </table>
</section>

<input type="hidden" id="pid" value="0" />
{include file="platform/openDialog" /}
<script type="text/javascript">

    function tab_switch(moudelID){
        if($(".pid_"+moudelID).css('display') != 'none'){
            $(".tab_jian_"+moudelID).hide();
            $(".tab_jia_"+moudelID).show();
            $(".pid_"+moudelID).hide(300);
        }else{
            $(".tab_jian_"+moudelID).show();
            $(".tab_jia_"+moudelID).hide();
            $(".pid_"+moudelID).show(500);
        }
    }
    function changeField(fieldid, fieldname, fieldvalue){
        $.ajax({
            type:"post",
            url:"{:__URL('PLATFORM_MAIN/system/editMoudel')}",
            data:{'moudelID':fieldid,'isEnable':fieldvalue},
            async:true,
            success: function (data) {
                if(data['code'] <= 0){
                    showMessage('error',data['message']);
                }
            }
        });
    }
    function changeField2(fieldid, fieldname, fieldvalue){
        $.ajax({
            type:"post",
            url:"{:__URL('PLATFORM_MAIN/system/editParam')}",
            data:{'paramID':fieldid,'isEnable':fieldvalue,},
            async:true,
            success: function (data) {
                if(data['code'] <= 0){
                    showMessage('error',data['message']);
                }
            }
        });
    }
    // $(".listOpen").click(function () {
    //     var moudel_id = $(this).attr("data_moudel_id");
    //     $.ajax({
    //         "url":"{:__URL('PLATFORM_MAIN/system/modifyfield')}",
    //         "data":{},
    //         success:function (res) {
    //
    //         }
    //     })
    // })
</script>
{/block}
